﻿using LeEdu.Entity;
using LeEdu.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace LPY.LeHealth.WebSite.Common
{
    public class UserAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {

            var currentUser = filterContext.HttpContext.Session[CommonService.UserSessionName] as UserInfo;
            if (null == currentUser)
            {

                //记录登录前的Url地址
                string returnUrl = filterContext.HttpContext.Request.Url.AbsolutePath;
                string redirectUrl = string.Format("?ReturnUrl={0}", returnUrl);

                //跳转到登录页面				
                filterContext.Result = new RedirectResult("/User/Login" + redirectUrl);

            }
        }
    }
}